

// {"发送方式":1,"序号":"59322","文本":"帮派","时间":1743835210,,"频道":6};
// {"频道":5,"发送方式":1,"序号":"59322","文本":"传闻","时间":1743835215,,"ID":"43270"};
// {"频道":4,"发送方式":1,"序号":"59322","文本":"门派","时间":1743835219,};
// {"时间":1743835223,,"频道":3,"发送方式":1,"序号":"59322","文本":"世界","ip":"127.0.0.1"};
// {"文本":"当前","时间":1743835231,,"频道":1,"发送方式":1,"序号":"59322"};
// {"发送方式":1,"序号":"59322","文本":"队伍","时间":1743835242,,"频道":2};
// {"发送方式":2,"超链接":[{"编号":2,"点击类型":"道具","名称":"体验月卡","类型":"道具"}],"频道":3,"文本":"[体验月卡]"}
// {"发送方式":2,"超链接":[{"编号":"24_1753461117068","点击类型":"召唤兽","名称":"毗舍童子","类型":"召唤兽"}],"频道":3,"文本":"[毗舍童子]1233231"}

// @ts-ignore
export async function execute(client_id, message_json) {
    let characters = G.Characters.get_current_login_characters(client_id);

    let text = message_json["文本"];
    let urls = message_json["超链接"];

    if (text.startsWith("@")) {
        await G.GmUtils.execute_cmd(client_id, text);
    } else {
        let now = Date.now();
        if(characters["最后发言时间"] && (now - characters["最后发言时间"]) <= 2000){
            ClientUtils.send_basic_prompt(client_id,"#Y/您说话的速度有点快哟！");
            return;
        }
        characters["最后发言时间"] = now;
        switch (message_json["频道"]) {
            case G.ChatUtils.chat_type_enum.当前[0]:
                // 发送给地图内所有玩家
                G.MapUtils.send_map_characters_chat(characters["地图数据"]["编号"], characters, text);
                break;
            case G.ChatUtils.chat_type_enum.队伍[0]:
                // 发送给队伍内所有玩家
                if (urls) {
                    let url_data_res = G.ChatUtils.build_url(characters, urls, text);
                    G.TeamUtils.send_team_characters_url_chat(characters["队伍"], characters, url_data_res[0], url_data_res[1]);
                } else {
                    G.TeamUtils.send_team_characters_chat(characters["队伍"], characters, text);
                }
                break;
            case G.ChatUtils.chat_type_enum.世界[0]:
                // 发送给所有在线玩家
                if (urls) {
                    let url_data_res = G.ChatUtils.build_url(characters, urls, text);
                    G.ChatUtils.send_all_url_chat(characters, url_data_res[0], url_data_res[1], G.ChatUtils.chat_type_enum.世界[1])
                } else {
                    G.ChatUtils.send_all_chat(characters, text, G.ChatUtils.chat_type_enum.世界[1]);
                    // onebot 发送聊天到群消息
                    G.OneBotUtils.send_http_group_text_message(1037049599, `${characters["名称"]}(${characters["模型"]}): ${text}`);
                }
                break;
            case G.ChatUtils.chat_type_enum.门派[0]:
                // TODO 发送给门派所有玩家
                G.ChatUtils.send_chat(client_id, characters, text, G.ChatUtils.chat_type_enum.门派[1]);
                break;
            case G.ChatUtils.chat_type_enum.传闻[0]:
                // 发送给所有在线玩家
                G.ChatUtils.send_all_chat(characters, text, G.ChatUtils.chat_type_enum.传闻[1]);
                break;
            case G.ChatUtils.chat_type_enum.帮派[0]:
                // 发送给帮派所有玩家
                if (characters["BPID"] !== 0) {
                    G.GangUtils.send_gang_chat(characters["BPID"], characters, text);
                }
                break;
            case G.ChatUtils.chat_type_enum.传音[0]:
                if (urls) {
                    let url_data_res = G.ChatUtils.build_url(characters, urls, text);
                    G.ChatUtils.send_cy_url_chat(characters, url_data_res[0], url_data_res[1],);
                } else {
                    G.ChatUtils.send_cy_chat(characters, text);
                }
                break;
            default:
                break;
        }
    }
}